import React from 'react';
// import { Router, Route, Switch, Redirect } from 'react-router';
import { HashRouter as Router, Route, Switch, Redirect } from "react-router-dom";
import { message } from "antd";

import Login from './components/login';
import MyLayout from './myLayout';

const $ = window.$;

function RouterConfig() {
  return (
    <Router>
      <Switch>
        <Route path="/login" exact={true} component={Login} />
        <Route path="/" render={props => {
          // return <MyLayout {...props} />
          if ($.cookie("username")) {
            return <MyLayout {...props} />
          } else {
            message.error("登录已过期，请重新登录");
            return <Redirect to={'/login'} />
          }
        }} />
      </Switch>
    </Router>
  );
}

export default RouterConfig;
